package com.xjz.model.enums;

import org.apache.commons.lang3.ObjectUtils;
import org.w3c.dom.stylesheets.LinkStyle;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * ClassName: FileUploadBizEnum
 * Package: com.xjz.model.enums
 * Description:
 *      文件上传业务类型枚举
 * @Author 许小健
 * @Create 2025/8/2 17:58
 * @Version 1.0
 */

public enum FileUploadBizEnum {
    USER_AVATAR("用户头像", "user_avatar");
    private final String text;

    private final String value;

    FileUploadBizEnum(String text,String value) {
        this.value = value;
        this.text = text;
    }

    /**
     * 获取值列表
     * @return
     */
    public static List<String> getValues() {
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }

    /**
     * 根据value获取枚举项
     * @param value
     * @return
     */
    public static FileUploadBizEnum getEnumByValue(String value) {
        if (ObjectUtils.isEmpty(value)) {
            return null;
        }

        for (FileUploadBizEnum fileUploadBizEnum : FileUploadBizEnum.values()) {
            if (fileUploadBizEnum.value.equals(value)) {
                return fileUploadBizEnum;
            }
        }

        return null;
    }

    public String getValue() {
        return value;
    }

    public String getText() {
        return text;
    }
}
